<!--
 * @Date: 2022-04-13 21:19:50
 * @LastEditors: sailornpg
 * @LastEditTime: 2022-04-24 13:32:26
 * @FilePath: \weibovue\src\components\fansAndFollowingCard\index.vue
 * @Description: 粉丝和关注显示卡片
-->
<template>
  <div class="Card" @click="goPersonal">
    <div class="avatar">
      <img :src="userInfo?.avatar" alt="" />
    </div>
    <div class="center">
      <div class="nickName">
        <span> {{ userInfo?.nickName }} </span>

        <i
          class="iconfont"
          :class="
            userInfo?.gender == 1
              ? 'icon-nan nan'
              : userInfo?.gender == 0
              ? 'icon-nv nv'
              : ''
          "
        ></i>
      </div>
      <div class="description">
        {{ userInfo?.description ? userInfo?.description : "暂无简介" }}
      </div>
    </div>
    <div class="unFollowBtn" v-if="isMy">取消关注</div>
  </div>
</template>
<script lang="ts" setup>
import { onMounted, PropType } from "vue";
import { useRouter } from "vue-router";
import { FansUserBaseInfo } from "./types";
const router = useRouter();
const props = defineProps({
  userInfo: {
    type: Object as PropType<FansUserBaseInfo>,
  },
  isMy: {
    type: Boolean,
    default: false,
  },
});
//跳转个人信息
const goPersonal = () => {
  router.push({ name: "Personal", params: { id: props.userInfo?.id } });
};
</script>
<style lang="less" scoped>
.Card {
  background-color: #fff;
  border-radius: 10px;
  padding: 15px;
  display: flex;
  align-items: center;
  margin-top: 10px;
  &:hover {
    background-color: #f2f2f2;
    cursor: pointer;
  }
  .avatar {
    width: 60px;
    height: 60px;
    img {
      width: 100%;
      height: 100%;
      border-radius: 100%;
      object-fit: cover;
    }
  }
  .center {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-left: 10px;
    padding-right: 20px;
    .nickName {
      font-size: 14px;
      font-weight: 700;
      margin-bottom: 5px;
    }
    .description {
      font-size: 14px;
      color: #939393;
      overflow: hidden; /*超出部分隐藏*/
      white-space: nowrap; /*不换行*/
      text-overflow: ellipsis; /*超出部分文字以...显示*/
    }
  }
  .unFollowBtn {
    background-color: #ccc;
    padding: 8px 10px;
    width: 80px;
    height: 30px;
    font-size: 14px;
    border-radius: 20px;
    color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    .iconfont {
      color: #fff;
      font-size: 12px;
      margin-right: 5px;
    }
    &:hover {
      cursor: pointer;
      background-color: #939393;
    }
  }
}
.nan {
  color: #77c2f9;
  font-size: 18px;
}
.nv {
  color: pink;
  font-size: 18px;
}
</style>
